<template>
	<view class="flex_ZC">
		<!-- #ifdef H5 ||MP-WEIXIN -->
		<uNavbar title="商家详情"> </uNavbar>
		<!-- #endif -->


		<view class="detail flex_Z" @click="goQualification">
			<text class="f28 c3 fw5 mart32" v-if="!isYmType">{{info.business_status_text}}</text>
			<view class="f24 c9 mart14 yytime" v-if="!isYmType">营业时间 <br />
				<view v-for="item in info.business_hours"> {{item.start}}至{{item.end}} </view>
			</view>
			<view class="xkz flex_ld">
				<text class="f28 c3 fw5">营业许可证</text>
				<view class="look ">
					<text class="f24 c6">查看</text>
					<u-icon name="arrow-right" color="#999999" size="12"></u-icon>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		detail
	} from "../../api/local.js"
	import {
		shopDetail
	} from "../../api/settled.js"
	export default {
		data() {
			return {
				id: "",
				info: {},
				isYmType: false
			}
		},
		onLoad(e) {
			this.id = e.id
			if (e.type) {
				this.shopDetail()
				this.isYmType = true
			} else {

				this.getdetail()
			}
		},
		methods: {
			shopDetail() {
				const data = {
					seller_id: this.id
				}
				shopDetail(data).then(res => {
					console.log(res);
					if (res.code == 1) {
						this.info = res.data.seller_auth
					}

				})
			},

			getdetail() {
				detail({
					id: this.id,
					latitude: uni.getStorageSync("latitude"),
					longitude: uni.getStorageSync("longitude")
				}).then(res => {
					this.info = res.data
				})
			},
			// getCode(){
			// 	// #ifdef H5
			// 		this.varify()
			// 	// #endif
			// },

			varify() {
				let appid = '192455824'; // 腾讯云控制台中对应这个项目的 appid
				//生成一个滑块验证码对象
				let captcha = new TencentCaptcha(appid, this.callback);
				// 滑块显示
				captcha.show();

			},
			callback(res) {
				// 用户操作验证码或者关闭刷新腾讯返回的内容 
				console.log(res);
				let that = this
				if (res.ret === 0) {
					
					console.log(this.isYmType);
					if (this.isYmType) {
						console.log(this.info.business_license_watermark);
						uni.setStorageSync("business_license_watermark", this.info.business_license_watermark)
					} else {
						console.log(this.info.auth_info.business_license_watermark);
						uni.setStorageSync("business_license_watermark", this.info.auth_info.business_license_watermark)
					}


					uni.navigateTo({
						url: '/pagesMy/groundCat/qualification?type=' + this.isYmType,
						success(res) {
							console.log(res);
						},
						fail(err) {
							console.log(err);
						}
					})
					console.log("成功")
					//成功，传递数据给后台进行验证
					// 这里后台会给一个借口,把后台需要的参数传过去

				} else {
					// uni.$u.toast('验证失败，请重新验证');
					console.log("验证失败")
					// 提示用户完成验证
				}
			},
			goQualification() {
				// #ifdef H5
					this.varify()
				// #endif
				// #ifdef MP-ALIPAY || MP-WEIXIN
				if (this.isYmType) {
					console.log(this.info.business_license_watermark);
					uni.setStorageSync("business_license_watermark", this.info.business_license_watermark)
				} else {
					console.log(this.info.auth_info.business_license_watermark);
					uni.setStorageSync("business_license_watermark", this.info.auth_info.business_license_watermark)
				}
				uni.navigateTo({
					url: '/pagesMy/groundCat/qualification?type=' + this.isYmType
				})
				// #endif

			}
		},
	}
</script>

<style scoped>
	.detail {
		width: 690rpx;
		/* height: 210rpx; */
		background: #FFFFFF;
		border-radius: 24rpx 24rpx 24rpx 24rpx;
		margin: 30rpx 0;
		padding: 20rpx 24rpx;
	}

	.mart32 {
		/* margin-top: 32rpx; */
	}

	.mart20 {
		margin-top: 20rpx;
	}

	.yytime {
		margin-bottom: 24rpx;
	}

	.xkz {
		/* margin-top: 24rpx; */
	}

	.look {
		height: 60rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}
</style>